home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_352 / mg / rexx / findtag.mg < prev    next >
Text File  |  1992-05-06  |  2KB  |  65 lines

  1. /*
  2.  * findtag searches the buffer *TAGS* to find a tag that matches it's
  3.  * argument, and then goes to the line it tags. If *TAGS* doesn't exist,
  4.  * it will prompt the user for a file name (default tags), and load that
  5.  * file into the buffer.
  6.  *
  7.  * The format of the *TAGS* buffer is the same as the tags file, which is
  8.  * what is created by the ctags program to be found on Fish Disk #197.
  9.  *
  10.  * Note that we may want to use etags instead of ctags....
  11.  */
  12.  
  13. options results
  14. options failat 2
  15. signal on failure
  16.  
  17. /* Find a tag to search for */
  18. if arg(1, 'Exists') then tag = arg(1)
  19. else do
  20.     'rexx-request "Find tag? "'
  21.     tag = result
  22.     if rc ~= 0 then exit 0
  23.     end
  24.  
  25. /* get our old buffer name */
  26. 'rexx-buffer tagbuffer'
  27. bufname = tagbuffer.1
  28.  
  29. /* Make sure we've got the tags buffer built, oh yes, oh yeah */
  30. 'switch-to-buffer *TAGS*'
  31. 'rexx-buffer tagbuffer'
  32. if tagbuffer.3 = 1 then do
  33.     'rexx-request "Tag file (tags)? "'
  34.     if rc = 0 then 'insert-file' file
  35.     else 'insert-file tags'
  36.     end
  37.  
  38. /* Find the line for the tag we're looking for */
  39. 'beginning-of-buffer'
  40. 'search-forward "\^Q\^J'tag'\^Q\^I"'
  41. if rc ~= 0 then do
  42.     'rexx-display "Can''t find tag' tag'"'
  43.     signal failure
  44.     end
  45.  
  46. 'rexx-line'
  47. parse var result '09'x file '09'x '/^' line '$/'
  48. 'find-file' file
  49. if rc ~= 0 then do
  50.     'rexx-display "Can''t find file' file'"'
  51.     signal failure
  52.     end
  53.  
  54. 'beginning-of-buffer'
  55. 'search-forward "'line'"'
  56. if rc ~= 0 then do
  57.     'rexx-display "Can''t find tag line"'
  58.     signal failure
  59.     end
  60. exit 0
  61.  
  62. failure:
  63.     'switch-to-buffer "'bufname'"'
  64.     exit 1
  65.